package com.race;

import java.util.Random;
import java.util.Scanner;

public class Range {

    private static Random rd = new Random();

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();

        while (m-- != 0) {
            int a = rd.nextInt(1000);
            int b = rd.nextInt(1000);
            int c = rd.nextInt(1000);
            int d = rd.nextInt(1000);
            int[] result = range(a, b, c, d);
            System.out.println("[" + result[0] + "," + result[1] + "]");
        }
    }

    private static int[] range(int a, int b, int c, int d) {
        int[] result = new int[]{0, -1};

        if (a > b) {
            int x = a;
            a = b;
            b = x;
        }

        if (c > d) {
            int x = c;
            c = d;
            d = x;
        }

        System.out.println(a + "," + b + "," + c + "," + d);
        if (a > d || c > b) {
            return result;
        }

        int start = a;
        int end = b;

        if (a < c) {
            start = c;
            if (b > d) {
                end = d;
            }
        } else {
            if (b > d) {
                end = d;
            }
        }


        result = new int[]{start, end};
        return result;
    }

}
